﻿using CADImport;
using CADImport.RasterImage;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;

namespace DwgConverter
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            RegisterCadImport();
            var fileName = @"D:\Workspace\三水办公楼结构B版.dwg";
            var cadImage = CADImage.CreateImageByExtension(fileName);

            if (cadImage is CADRasterImage)
            {
                //(cadImage as CADRasterImage).Control ;
                //currentDrawingInfo.AutoCADDrawing = false;//非AutoCAD文件
            }
            else
            {
                //currentDrawingInfo.AutoCADDrawing = true;
            }

            if (cadImage != null)
            {
                CADImage.LastLoadedFilePath = Path.GetDirectoryName(fileName);


                if (CADConst.IsWebPath(fileName))
                    cadImage.LoadFromWeb(fileName);
                else
                    cadImage.LoadFromFile(fileName);

                cadImage.Print(true, true, "aaa");
                //SetCADImageOptions();
            }
        }


        private static void RegisterCadImport()
        {
            #region //控件注册信息//
            ArrayList regDat = new ArrayList();
            regDat.Add("Zhengzhou GL Technology Co., Ltd");
            regDat.Add("dinglianying@gltech.cn");
            string key = "66A5FF46A04C411043E5CDB70B254393EE0783E207B4D36A1628316F4CE1797ED45034B4E7EDE4DBF5D86A3BDDDDE7A61E3546BDC8FB3FB51CEAE8857028CD3A|27D61BF2606898846609001A0EEB150996DCBBB3427B064BC479C44680DB8ACD880A98D83BB8B81AC6C87312E4D6CA8DB3ADBEB450B8DEA9116F41D9C1B0D523|";
            CADImport.Protection.Register(key, regDat, false);
            #endregion/控件注册信息/
        }
    }
}
